#include <math.h>

/* supported functions

// full real range support
double li2(double); // H_{2}(z)==H_{0,1}(z)
double li3(double); // H_{3}(z)==H_{0,0,1}(z)
double li4(double); // H_{4}(z)==H_{0,0,0,1}(z)
double s2p2(double); // H_{3,1}(z)==H_{0,0,1,1}(z)

// (-1,1) range support
double h0p0m(double); // H_{2,-2}(z)==H_{0,1,0,-1}(z)
double h0m0p(double); // H_{-2,2}(z)==H_{0,-1,0,1}(z)
double h00mp(double); // H_{-3,1}(z)==H_{0,0,-1,1}(z)
double h00pm(double); // H_{3,-1}(z)==H_{0,0,1,-1}(z)
double h0mpp(double); // H_{-2,1,1}(z)==H_{0,-1,1,1}(z)
double h0pmm(double); // H_{2,-1,-1}(z)==H_{0,1,-1,-1}(z)
double h0mpm(double); // H_{-2,1,-1}(z)==H_{0,-1,1,-1}(z)
double h0pmp(double); // H_{2,-1,1}(z)==H_{0,1,-1,1}(z)
double h0mmp(double); // H_{-2,-1,1}(z)==H_{0,-1,-1,1}(z)
double h0ppm(double); // H_{2,1,-1}(z)==H_{0,1,1,-1}(z)
double hmpmp(double); // H_{-1,1,-1,1}(z)
double hpmpm(double); // H_{1,-1,1,-1}(z)

*/

//-----------------

  double li2(double z) // PolyLog[2,z] or HPL[{2},z]==HPL[{0,1},z]
  {

    const double pi2o6 = 1.644934066848226; // zeta2

    static double cof_odd[9] =
    { 1.,0.027777777777777776,-0.0002777777777777778,4.72411186696901e-6,
      -9.185773074661964e-8,1.8978869988971e-9,4.0647616451442256e-11,
      8.921691020456452e-13,-1.9939295860721074e-14 };

    if ( z==0. ) return 0.;
    else if ( z==1. ) return pi2o6;
    else if ( z==-1. ) return -pi2o6/2.;
    else if ( -1<z && z<=0.5 ) {
      double u = -log(1.-z);
      double t = u*u, f = 0.;
      int i; for (i=8; i>=0; i--) f = f*t+cof_odd[i];
      return f*u - t/4.;
    }

    if ( z<-1. ) {
      double t = 1./z;
      double lnnt = log(-t);
      return -pi2o6 - li2(t) - lnnt*lnnt/2.;
    }
    else if ( 0.5<z && z<1. ) {
      double t = 1.-z;
      return pi2o6 - log(t)*log(1-t) - li2(t);
    }
    else if ( 1.<z && z<2. ) {
      double t = 1.-1./z;
      double lnmt = log(1.-t), lnt = log(t);
      // omit imaginary part of pi*log(z)*sign(Im(z))
      return pi2o6 - lnmt*lnmt/2. + lnmt*lnt + li2(t);
    }
    else if ( z>=2. ) {
      double t = 1./z;
      double lnt = log(t);
      // omit imaginary part of pi*log(z)*sign(Im(z))
      return 2.*pi2o6 - li2(t) - lnt*lnt/2.;
    }

  }

  double li3(double z) // PolyLog[4,z] or HPL[{3},z]==HPL[{0,0,0,1},z]
  {

    const double pi2o6 = 1.644934066848226; // zeta2
    const double zeta3 = 1.202056903159594;

    static double cof[17] =
    { 1.,-0.375,0.07870370370370369,-0.008680555555555556,0.00012962962962962963,
      0.00008101851851851852,-3.4193571608537595e-6,-1.328656462585034e-6,
      8.660871756109852e-8,2.52608759553204e-8,-2.1446944683640645e-9,
      -5.140110622012978e-10,5.249582114600829e-11,1.0887754406636318e-11,
      -1.2779396094493697e-12,-2.369824177308745e-13,3.104357887965462e-14 };
    static double cofm_even[9] = 
    { 1.202056903159594,0.75,-0.003472222222222222,0.000011574074074074073,
      -9.841899722852104e-8,1.1482216343327454e-9,-1.5815724990809165e-11,
      2.4195009792525154e-13,-3.982897776989488e-15 };

    if ( z==0. ) return 0.;
    else if ( z==1. ) return zeta3;
    else if ( z==-1. ) return -3.*zeta3/4.;
    else if ( -1.<z && z<0.5 ) {
      double u = -log(1.-z);
      double f = 0.;
      int i; for (i=16; i>=0; i--) f = f*u+cof[i];
      return f*u;
    }
    else if ( 0.5<=z && z<1. ) {
      double u = -log(z);
      double t = u*u, f = 0.;
      int i; for (i=8; i>=0; i--) f = f*t+cofm_even[i];
      return f - pi2o6*u + u*t/12. - t*log(u)/2.;
    }

    if ( z<-1. ) {
      double t = 1./z;
      double lnnt = log(-t);
      return li3(t) + pi2o6*lnnt + lnnt*lnnt*lnnt/6.;
    }
    else if ( z>1. ) {
      double t = 1./z;
      double lnt = log(t);
      // omit imaginary part of pi/2*log(z)^2*sign(Im(z))
      return -2.*pi2o6*lnt + lnt*lnt*lnt/6. + li3(t);
    }

  }
 
  double li4(double z) // PolyLog[4,z] or HPL[{4},z]==HPL[{0,0,0,1},z]
  {

    const double pi2o6 = 1.644934066848226; // zeta2
    const double zeta3 = 1.202056903159594;
    const double pi4o90 = 1.082323233711138; // zeta4

    static double cof[17] =
    { 1.,-0.4375,0.11651234567901235,-0.019820601851851853,0.001927932098765432,
      -0.000031057098765432096,-0.000015624009114857836,8.485123546773206e-7,
      2.290961660318971e-7,-2.1832614218526917e-8,-3.882824879172015e-9,
      5.446292103220332e-10,6.960805210682725e-11,-1.3375737686445216e-11,
      -1.2784852685266572e-12,3.260562858024892e-13 };
    static double cofm_odd[8] =
    { -1.202056903159594,-0.3055555555555556,0.0006944444444444445,
      -1.6534391534391535e-6,1.0935444136502338e-8,-1.0438378493934049e-10,
      1.2165942300622436e-12,-1.61300065283501e-14 };

    if ( z==0. ) return 0.;
    else if ( z==1. ) return pi4o90;
    else if ( z==-1. ) return -7.*pi4o90/8.;
    else if ( -1.<z && z<0.5 ) {
      double u = -log(1.-z);
      double f = 0.;
      int i; for (i=16; i>=0; i--) f = f*u+cof[i];
      return f*u;
    }
    else if ( 0.5<=z && z<1. ) {
      double u = -log(z);
      double t = u*u, f = 0.;
      int i; for (i=7; i>=0; i--) f = f*t+cofm_odd[i];
      return f*u + pi4o90 + pi2o6*t/2. - t*t/48. + t*u*log(u)/6.;
    }

    if ( z<-1. ) {
      double t = 1./z;
      double lnnt = log(-t);
      double lnnt2 = lnnt*lnnt;
      return -7.*pi4o90/4. - li4(t) - pi2o6/2.*lnnt2 - lnnt2*lnnt2/24.;
    }
    else if ( z>1. ) {
      double t = 1./z;
      double lnt = log(t);
      double lnt2 = lnt*lnt;
      // omit imaginary part of pi/6*log(z)^3*sign(Im(z))
      return 2.*pi4o90 + pi2o6*lnt2 - lnt2*lnt2/24. - li4(t);
    }

  }

  double s2p2(double z) // PolyLog[2,2,z] or HPL[{3,1},z]==HPL[{0,0,1,1},z]
  {

    const double pi2o6 = 1.644934066848226; // zeta2
    const double zeta3 = 1.202056903159594;
    const double pi4o90 = 1.082323233711138; // zeta4

    static double cof[18] =
    { 0.,0.125,-0.06944444444444445,0.018229166666666668,-0.0024305555555555556,
      0.00006751543209876543,0.0000248015873015873,-1.722332451499118e-6,
      -4.2101459925534e-7,4.294348912404468e-8,8.141935225268558e-9,-1.0554360477199982e-9,
      -1.672817066335585e-10,2.5744345773117865e-11,3.5647314427653725e-12,
      -6.25827037844391e-13,-7.79007947558238e-14,1.51973086355923e-14 };

    if ( z==0. ) return 0.;
    else if ( z==1. ) return pi4o90/4.;
    else if ( -1.<=z && z<=0.5 ) {
      double u = -log(1.-z);
      double f = 0.;
      int i; for (i=17; i>=0; i--) f = f*u+cof[i];
      return f*u;
    }

    if ( z<-1. ) {
      double t = 1./z;
      double lnnt = log(-t);
      return -7.*pi4o90/4. - 2.*li4(t) + li3(t)*lnnt + lnnt*lnnt*lnnt*lnnt/24.
             + s2p2(t) - lnnt*zeta3;
    }
    else if ( 0.5<z && z<1. ) {
      double t = 1.-z;
      double lnmt = log(1.-t), lnt = log(t);
      return pi4o90/4. - li3(t)*lnmt - li3(1.-t)*lnt
             + (pi2o6 - lnmt*lnt/4.)*lnmt*lnt
             - s2p2(t) + (lnmt + lnt)*zeta3;
    }
    else if ( z>1. ) {
      double t = 1./z;
      double lnt = log(t);
      // omit imaginary part of (li3(1/z) + zeta2*log(z) - log(z)^3/6. - zeta3)*pi*sign(Im(z))
      return 2.*pi4o90 - 2.*li4(t) + li3(t)*lnt - 3.*pi2o6*lnt*lnt/2. + 
             lnt*lnt*lnt*lnt/24. + s2p2(t) - lnt*zeta3;
    }

  }

//-----------------

  double h0p0m(double z) { // HPL[{2,-2},z]==HPL[{0,1,0,-1},z]
  if ( z>=-0.5 && z<=0.5 ) {
  return
  z*z*(0.25 + z*(0.08333333333333333 + z*(0.05381944444444445 + 
  z*(0.03194444444444444 + z*(0.023294753086419755 + 
  z*(0.016547619047619047 + z*(0.012988148384353741 + 
  z*(0.010069339464180734 + z*(0.008279621756109851 + 
  z*(0.006760017980256075 + z*(0.0057376849890340455 + 
  z*(0.004847823632996793 + z*(0.00421020078438659 + 
  z*(0.0036448769463264226 + z*(0.0032208662397183187 + 
  z*(0.002839569229646677 + z*(0.002543505293149217 + 
  z*(0.0022742639756987808 + z*(0.0020594484458243824 + 
  z*(0.0018623115154869682 + z*(0.0017015432893097069 + 
  z*(0.0015528938304790526 + z*(0.0014294638810619109 + 
  z*(0.0013146161350088793 + z*(0.001217803379261168 + 
  z*(0.0011272370294097684 + z*(0.0010499075721329136 + 
  z*(0.0009772318981547236 + z*(0.0009144900966557946 + 
  z*(0.0008552861351499521 + z*(0.000803682186138116 + 
  z*(0.000754815423420965 + z*(0.0007118618250440979 + 
  z*(0.0006710589533451943 + z*(0.0006349255743661075 +
  z*(0.000600505434214904 + z*(0.0005698216063920521 + 
  z*(0.0005405193154861933 + z*(0.0005142420881565149 + 
  z*(0.0004890912201370753 + z*(0.000466415660458075 + 
  z*(0.000444667567130345 + (0.00042496444447657393 + 
  0.0004060319188054456*z)*z))))))))))))))))))))))))))))))))))))))))))
  ;
  }
  else if ( z>0.5 && z<=1. ) {
  double mz = 1.-z;
  return
  0.5685258800390968 + mz*(-0.07118146894936672 + 
  mz*(-0.1765475663986277 + mz*(-0.08810136301107431 + 
  mz*(-0.05083426963307964 + mz*(-0.032773751795888546 + 
  mz*(-0.022814568625728355 + mz*(-0.016776113468712883 + 
  mz*(-0.012848340848849598 + mz*(-0.010153045109237709 + 
  mz*(-0.00822437845567979 + mz*(-0.006797146484751011 + 
  mz*(-0.005711540070000454 + mz*(-0.004866655361976512 + 
  mz*(-0.004196255296802794 + mz*(-0.0036554070873104846 + 
  mz*(-0.0032127610878645192 + mz*(-0.002845906388366043 + 
  mz*(-0.0025384783771397954 + mz*(-0.002278301982482696 + 
  mz*(-0.0020561675633899348 + mz*(-0.001865004602585433 + 
  mz*(-0.0016993120490398118 + mz*(-0.0015547580957411006 + 
  mz*(-0.0014278941546273741 + mz*(-0.0013159472532127646 + 
  mz*(-0.001216667209093119 + mz*(-0.0011282126658274105 + 
  mz*(-0.0010490650936318072 + mz*(-0.0009779631788540636 + 
  mz*(-0.0009138522593560329 + mz*(-0.0008558449879525372 + 
  mz*(-0.000803190462327439 + mz*(-0.000755249801123712 + 
  mz*(-0.0007114766725120469 + mz*(-0.0006714016599379848 + 
  mz*(-0.0006346196245556063 + mz*(-0.0006007794254376184 + 
  mz*(-0.0005695755079114292 + mz*(-0.0005407409818698992 + 
  mz*(-0.000514041895890072 + mz*(-0.0004892724767543797 + 
  mz*(-0.000466251152734758 + mz*(-0.000444817216562525 + 
  (-0.00042482801313229596 - 
  0.0004061565597156154*mz)*mz)))))))))))))))))))))))))))))))))))))))))))
  + (mz>0.?log(mz):0.)*
  mz*(0.8224670334241131 + mz*(0.41123351671205655 + 
  mz*(0.27415567780803773 + mz*(0.20561675835602827 + 
  mz*(0.16449340668482262 + mz*(0.13707783890401887 + 
  mz*(0.11749529048915902 + mz*(0.10280837917801414 + 
  mz*(0.09138522593601256 + mz*(0.08224670334241131 + 
  mz*(0.07476973031128302 + mz*(0.06853891945200943 + 
  mz*(0.06326669487877794 + mz*(0.05874764524457951 + 
  mz*(0.05483113556160755 + mz*(0.05140418958900707 + 
  mz*(0.048380413730830185 + mz*(0.04569261296800629 + 
  mz*(0.04328773860126911 + mz*(0.041123351671205656 + 
  mz*(0.039165096829719664 + mz*(0.0373848651556415 + 
  mz*(0.035759436235831006 + mz*(0.03426945972600472 + 
  mz*(0.03289868133696454 + mz*(0.03163334743938897 + 
  mz*(0.030461741978670857 + mz*(0.029373822622289755 + 
  mz*(0.028360932187038383 + mz*(0.027415567780803774 + 
  mz*(0.0265311946265843 + mz*(0.025702094794503534 + 
  mz*(0.02492324343709434 + mz*(0.024190206865415093 + 
  mz*(0.02349905809783181 + mz*(0.02284630648400314 + 
  mz*(0.022228838741192247 + mz*(0.021643869300634555 + 
  mz*(0.02108889829292598 + mz*(0.020561675835602825 + 
  mz*(0.020060171546929587 + mz*(0.019582548414859832 + 
  mz*(0.01912714031218868 + (0.018692432577820755 + 
  0.018277045187202516*mz)*mz)))))))))))))))))))))))))))))))))))))))))))
  ;
  }
  else if ( z<-0.5 && z>=-1. ) {
  double pz = 1.+z;
  return
  0.2029356063208384 + pz*(-0.38889584616810613 + 
  pz*(0.21678559362800348 + pz*(0.060284870759567344 + 
  pz*(0.01200116071045565 + pz*(-0.0026197635838459132 + 
  pz*(-0.006742811481719541 + pz*(-0.00742950282255711 + 
  pz*(-0.007005724695920326 + pz*(-0.00627743313036816 + 
  pz*(-0.00552585890755862 + pz*(-0.004842511394031149 + 
  pz*(-0.004249266715122074 + pz*(-0.00374323767560273 + 
  pz*(-0.0033138511401015897 + pz*(-0.002949265455797892 + 
  pz*(-0.0026386172496219162 + pz*(-0.0023726404394080122 + 
  pz*(-0.00214367425498143 + pz*(-0.0019454683219048696 + 
  pz*(-0.0017729450864292298 + pz*(-0.001621978272826556 + 
  pz*(-0.0014892048643219205 + pz*(-0.0013718720837661708 + 
  pz*(-0.0012677152951480267 + pz*(-0.0011748614246291159 + 
  pz*(-0.0010917527754916584 + pz*(-0.0010170868880313329 + 
  pz*(-0.0009497689358298755 + pz*(-0.0008888738976865866 + 
  pz*(-0.0008336163595935378 + pz*(-0.0007833262881629353 + 
  pz*(-0.0007374294950769043 + pz*(-0.0006954318029195779 + 
  pz*(-0.0006569061454356727 + pz*(-0.0006214820056645656 + 
  pz*(-0.0005888367259749248 + pz*(-0.0005586883243551867 + 
  pz*(-0.0005307895286775534 + pz*(-0.0005049228005516368 + 
  pz*(-0.0004808961669636562 + pz*(-0.00045853971428695683 + 
  pz*(-0.00043770262781011454 + pz*(-0.0004182506824504627 + 
  (-0.00040006410816125285 - 0.0003830357677389838*pz)*pz)))))))))))))))))))))))))))))))))))))))))))
  + (pz>0.?log(pz):0.)*
  pz*pz*pz*(0.08333333333333331 + pz*(0.10416666666666667 + 
  pz*(0.10416666666666667 + pz*(0.09791666666666667 + 
  pz*(0.09027777777777778 + pz*(0.08286210317460317 + 
  pz*(0.07615189594356261 + pz*(0.07022982804232804 + 
  pz*(0.06504298941798942 + pz*(0.06050056617764951 + 
  pz*(0.056509439634439634 + pz*(0.05298603017353017 + 
  pz*(0.04985906928168833 + pz*(0.04706906746527282 + 
  pz*(0.04456675516943374 + pz*(0.04231137356684451 + 
  pz*(0.04026912524592847 + pz*(0.03841186813363924 + 
  pz*(0.03671604971769226 + pz*(0.03516185008547579 + 
  pz*(0.03373249678295171 + pz*(0.03241371745708401 + 
  pz*(0.031193301674632717 + pz*(0.03006074885342831 + 
  pz*(0.029006984086836204 + pz*(0.028024127606554365 + 
  pz*(0.027105306770545436 + pz*(0.02624450191259539 + 
  pz*(0.02543641928560305 + pz*(0.02467638579361763 + 
  pz*(0.02396026133695511 + pz*(0.02328436546838163 + 
  pz*(0.022645415736462785 + pz*(0.022040475620627484 + 
  pz*(0.02146691037614924 + pz*(0.020922349432564713 + 
  pz*(0.02040465424612402 + pz*(0.019911890710998494 + 
  pz*(0.01944230539684123 + pz*(0.018994305010860114 + 
  pz*(0.018566438587715377 + (0.01815738199562307 + 
  0.017765924416171502*pz)*pz)))))))))))))))))))))))))))))))))))))))))
  ;
  }
  return 0.; // out of supported (-1,1) range
  }

  double h0m0p(double z) { return h0p0m(-z); }

  double h00mp(double z) { // HPL[{-3,1},z]==HPL[{0,0,-1,1},z]
  if ( z>=-0.5 && z<=0.5 ) {
  return
  z*z*(0.125 + z*(-0.018518518518518517 + 
  z*(0.013020833333333334 + z*(-0.004666666666666667 + 
  z*(0.003626543209876543 + z*(-0.0017978620019436346 + 
  z*(0.0014834449404761904 + z*(-0.000870403030896858 + 
  z*(0.0007456349206349206 + z*(-0.0004850750718519314 + 
  z*(0.000426240747421303 + z*(-0.00029731938015961683 + 
  z*(0.0002660837300050128 + z*(-0.0001951719062830174 + 
  z*(0.00017709273690719003 + z*(-0.00013492201310235098 + 
  z*(0.0001237474931041864 + z*(-0.00009711908794693972 + 
  z*(0.00008984642539692849 + z*(-0.00007221373536069841 + 
  z*(0.00006727934361330536 + z*(-0.00005514390608530699 + 
  z*(0.00005167926549547854 + z*(-0.000043055839970741034 + 
  z*(0.000040552315631703954 + z*(-0.000034257275876710366 + 
  z*(0.00003240356223206666 + z*(-0.000027701369978434602 + 
  z*(0.00002629968411202708 + z*(-0.00002271686541879755 + 
  z*(0.000021637457342759 + z*(-0.000018859843676643206 + 
  z*(0.00001801519520940762 + z*(-0.000015828745604773758 + 
  z*(0.000015158369692560515 + z*(-0.00001341383765222841 + 
  z*(0.000012875020878140994 + (-0.000011466180416926592 + 
  0.000011028177840510845*z)*z)))))))))))))))))))))))))))))))))))))
  ;
  }
  else if ( z>0.5 && z<=1. ) {
  double mz = 1.-z;
  return
  0.11787599965050931 + mz*(-0.24307035167006186 + 
  mz*(0.1695850873974754 + mz*(0.057319034898041264 + 
  mz*(0.019460708934504134 + mz*(0.005444482359742819 + 
  mz*(-0.00026498326249163595 + mz*(-0.0026948639916988815 + 
  mz*(-0.0037033645408386384 + mz*(-0.004056059933813527 + 
  mz*(-0.0040955435196849965 + mz*(-0.003984867031652434 + 
  mz*(-0.0038051302711025747 + mz*(-0.0035978228942377677 + 
  mz*(-0.0033844155560484868 + mz*(-0.0031759131896212656 + 
  mz*(-0.002977717485446535 + mz*(-0.002792189179012583 + 
  mz*(-0.0026200358370939147 + mz*(-0.002461079220282575 + 
  mz*(-0.0023146855105914133 + mz*(-0.002180008051543475 + 
  mz*(-0.0020561238963748008 + mz*(-0.0019421093938340739 + 
  mz*(-0.0018370804848313188 + mz*(-0.0017402125240931071 + 
  mz*(-0.0016507482855790678 + mz*(-0.0015679992589630598 + 
  mz*(-0.001491343264628145 + mz*(-0.001420220181671067 + 
  mz*(-0.001354126845647452 + mz*(-0.0012926117285392974 + 
  mz*(-0.0012352697451736838 + mz*(-0.001181737368576699 + 
  mz*(-0.0011316881399137113 + mz*(-0.0010848286015647662 + 
  mz*(-0.001040894649137425 + mz*(-0.0009996482803615592 + 
  mz*(-0.0009608747099976722 + mz*(-0.0009243798164837586 + 
  mz*(-0.0008899878857988458 + mz*(-0.0008575396195364404 + 
  mz*(-0.0008268903766040225 + mz*(-0.0007979086207714758 + 
  (-0.0007704745491839693 - 0.0007444788797435903*mz)*mz)))))))))))))))))))))))))))))))))))))))))))
  + (mz>0.?log(mz):0.)*
  mz*mz*mz*(0.08333333333333331 + mz*(0.11458333333333331 + 
  mz*(0.125 + mz*(0.12690972222222222 + mz*(0.1251736111111111 + 
  mz*(0.12186879960317461 + mz*(0.11794257054673721 + 
  mz*(0.11384553778108465 + mz*(0.10979564525462963 + 
  mz*(0.10589649948455288 + mz*(0.10219362289186508 + 
  mz*(0.09870248274248693 + mz*(0.09542297903789952 + 
  mz*(0.09234714009838696 + mz*(0.08946328396977113 + 
  mz*(0.08675828560630347 + mz*(0.08421880501022 + 
  mz*(0.08183193578334201 + mz*(0.07958552714929552 + 
  mz*(0.07746832166642934 + mz*(0.07546998981484063 + 
  mz*(0.07358110830189396 + mz*(0.07179310926278117 + 
  mz*(0.07009821610384544 + mz*(0.0684893750222976 + 
  mz*(0.06696018726359983 + mz*(0.06550484482138515 + 
  mz*(0.06411807089105795 + mz*(0.06279506557252894 + 
  mz*(0.061531456850535377 + mz*(0.06032325662452087 + 
  mz*(0.05916682143017497 + mz*(0.05805881744020073 + 
  mz*(0.0569961893212732 + mz*(0.05597613253823515 + 
  mz*(0.05499606872361556 + mz*(0.054053623763468714 + 
  mz*(0.05314660828512549 + mz*(0.052273000266317496 + 
  mz*(0.051430929516980035 + mz*(0.05061866381423739 + 
  (0.04983459649740215 + 0.049077235353298235*mz)*mz)))))))))))))))))))))))))))))))))))))))))
  ;
  }
  else if ( z<-0.5 && z>=-1. ) {
  double pz = 1.+z;
  return
  0.17284527823898443 + pz*(-0.5082152128046846 + 
  pz*(-0.025367484214889657 + pz*(0.027143854492566916 + 
  pz*(0.03074665221539541 + pz*(0.027192853145843326 + 
  pz*(0.023045126763805962 + pz*(0.01946135054551329 + 
  pz*(0.01654880207588566 + pz*(0.014208177233068359 + 
  pz*(0.012319611554332088 + pz*(0.010781905714441806 + 
  pz*(0.009516631729990788 + pz*(0.008464464062527266 + 
  pz*(0.007580665517930546 + pz*(0.006831318232838439 + 
  pz*(0.006190477776868236 + pz*(0.005638095252443409 + 
  pz*(0.005158514088056898 + pz*(0.004739381151617816 + 
  pz*(0.004370853053028589 + pz*(0.00404501264546344 + 
  pz*(0.0037554359417996883 + pz*(0.0034968674880552428 + 
  pz*(0.00326497463881497 + pz*(0.003056159777031414 + 
  pz*(0.002867415494554458 + pz*(0.0026962119247396915 + 
  pz*(0.0025404083582379056 + pz*(0.0023981833605155323 + 
  pz*(0.0022679791049992695 + pz*(0.002148456716489975 + 
  pz*(0.0020384602075003005 + pz*(0.0019369871697000746 + 
  pz*(0.0018431648124256107 + pz*(0.0017562302615026781 + 
  pz*(0.0016755142736930087 + pz*(0.0016004277057991532 + 
  pz*(0.0015304502179090858 + pz*(0.001465120798353644 + 
  pz*(0.0014040297816888987 + pz*(0.0013468120962908219 + 
  pz*(0.0012931415293387684 + pz*(0.0012427258373340043 + 
  (0.0011953025623162514 + 0.0011506354394592022*pz)*pz))))))))))))))))))))))))))))))))))))))))))
  )
  + (pz>0.?log(pz):0.)*
  pz*pz*(-0.34657359027997264 + pz*(-0.34657359027997264 + 
  pz*(-0.31769245775664157 + pz*(-0.28881132523331055 + 
  pz*(-0.26378101037975693 + pz*(-0.24260151319598083 + 
  pz*(-0.22465395227076798 + pz*(-0.2093194461929041 + 
  pz*(-0.19608913691316868 + pz*(-0.18456418974433464 + 
  pz*(-0.17443495560321542 + pz*(-0.16546013325271133 + 
  pz*(-0.15745005329817668 + pz*(-0.15025408393810752 + 
  pz*(-0.1437513169443089 + pz*(-0.1378436923467023 + 
  pz*(-0.13245089630312715 + pz*(-0.12750654263968755 + 
  pz*(-0.12295528703549251 + pz*(-0.11875062379704035 + 
  pz*(-0.11485318674254275 + pz*(-0.1112294260157127 + 
  pz*(-0.10785056801244922 + pz*(-0.10469179059288448 + 
  pz*(-0.10173156354017346 + pz*(-0.09895111699959716 + 
  pz*(-0.09633400988527285 + pz*(-0.09386577700814513 + 
  pz*(-0.09153363867173564 + pz*(-0.08932626019905594 + 
  pz*(-0.0872335516450128 + pz*(-0.08524650006160327 + 
  pz*(-0.08335702829558458 + pz*(-0.08155787553803003 + 
  pz*(-0.07984249580527517 + pz*(-0.07820497127942685 + 
  pz*(-0.07663993802424987 + pz*(-0.07514252205639457 + 
  pz*(-0.07370828412072826 + pz*(-0.07233317181324705 + 
  pz*(-0.07101347793183986 + pz*(-0.06974580412642606 + 
  (-0.0685270290752229 - 0.06735428054050074*pz)*pz))))))))))))))))))))))))))))))))))))))))))
  ;
  }
  return 0.; // out of supported (-1,1) range
  }

  double h00pm(double z) { return h00mp(-z); }

  double h0mpp(double z) { // HPL[{-2,1,1},z]==HPL[{0,-1,1,1},z]
  if ( z>=-0.5 && z<=0.5 ) {
  return
  z*z*z*(0.05555555555555555 + z*z*(0.018333333333333333 + 
  z*(-0.0011574074074074073 + z*(0.008616780045351474 + 
  z*(-0.0011284722222222221 + z*(0.004892955124436606 + 
  z*(-0.000943452380952381 + z*(0.0031177030040666406 + 
  z*(-0.0007706404320987655 + z*(0.0021457317611163766 + 
  z*(-0.0006322456832660914 + z*(0.0015603225111161618 + 
  z*(-0.0005246161844934166 + z*(0.0011823219906820994 + 
  z*(-0.0004408168022861585 + z*(0.0009249609285277984 + 
  z*(-0.00037489459612840214 + z*(0.0007422785063685827 + 
  z*(-0.0003223633992852974 + z*(0.000608170147822012 + 
  z*(-0.0002799511577848087 + z*(0.000506955754420269 + 
  z*(-0.0002452796145007808 + z*(0.0004287745426938499 + 
  z*(-0.00021660759673223744 + z*(0.0003671830608424562 + 
  z*(-0.0001926458479662949 + z*(0.0003178318311715928 + 
  z*(-0.00017242757533746626 + z*(0.00027770179017718707 + 
  z*(-0.0001552184659264195 + z*(0.00024464597384181376 + 
  z*(-0.00014045383902165634 + z*(0.00021710485618884953 + 
  z*(-0.00012769433787038922 + z*(0.00019392418304172573 + 
  z*(-0.00011659433654738427 + z*(0.00017423528521667118 + 
  z*(-0.0001068791418268046 + z*(0.0001573745801141301 + 
  (-0.00009832834343750963 + 0.00014282828538701066*z)*z))))))))))))))))))))))))))))))))))))))))
  ;
  }
  else if ( z>0.5 && z<=1. ) {
  double mz = 1.-z;
  double lnmz = mz>0.?log(mz):0.;
  return
  0.09309712599176856 + mz*(-0.5372131936080402 + 
  mz*(0.1688934031959799 + mz*(0.08366041694546804 + 
  mz*(0.04610758122761954 + mz*(0.028598738593206774 + 
  mz*(0.019323890957301942 + mz*(0.013887176349105135 + 
  mz*(0.010446503924332412 + mz*(0.008137451470515547 + 
  mz*(0.0065150469355109986 + mz*(0.005332502474529377 + 
  mz*(0.004444401690240823 + mz*(0.003760684603485151 + 
  mz*(0.0032232110779326223 + mz*(0.002793109366450136 + 
  mz*(0.0024436011804837843 + mz*(0.002155756907380138 + 
  mz*(0.0019158908603147465 + mz*(0.001713911157874566 + 
  mz*(0.0015422446808620247 + mz*(0.0013951191135592386 + 
  mz*(0.0012680727556939192 + mz*(0.0011576131552887212 + 
  mz*(0.0010609751014073465 + mz*(0.0009759462614728417 + 
  mz*(0.0009007396942099996 + mz*(0.000833899374768271 + 
  mz*(0.0007742293149066437 + mz*(0.0007207397780836719 + 
  mz*(0.0006726060360864733 + mz*(0.0006291364338521857 + 
  mz*(0.0005897474373595876 + mz*(0.0005539439728938222 + 
  mz*(0.0005213038133615039 + mz*(0.0004914650870397816 + 
  mz*(0.0004641162151341298 + mz*(0.00043898775313928884 + 
  mz*(0.0004158457352790128 + mz*(0.0003944862137375063 + 
  mz*(0.00037473075373688214 + mz*(0.0003564226979530967 + 
  mz*(0.00033942405372112266 + mz*(0.00032361288714899406 + 
  (0.00030888113196164343 + 0.00029513273933043024*mz)*mz)))))))))))))))))))))))))))))))))))))))))))
  + lnmz*
  mz*mz*(-0.375 + mz*(-0.2569444444444444 + 
  mz*(-0.1857638888888889 + mz*(-0.14335069444444445 + 
  mz*(-0.11605034722222222 + mz*(-0.09724489795918367 + 
  mz*(-0.08358391794217687 + mz*(-0.0732413203876265 + 
  mz*(-0.06515204732428272 + mz*(-0.05865812862649603 + 
  mz*(-0.053333054836632574 + mz*(-0.04888899311396593 + 
  mz*(-0.0451249927974431 + mz*(-0.04189665596000564 + 
  mz*(-0.03909762530874904 + mz*(-0.036647870121180266 + 
  mz*(-0.03448603662848433 + mz*(-0.03256431248833777 + 
  mz*(-0.030844893827881865 + mz*(-0.029297501476176043 + 
  mz*(-0.027897600665209542 + mz*(-0.026625102589193112 + 
  mz*(-0.02546340244153099 + mz*(-0.024398656540264085 + 
  mz*(-0.02341923205099567 + mz*(-0.02251528311943099 + 
  mz*(-0.021678420817695387 + mz*(-0.02090145356456614 + 
  mz*(-0.020178181082657388 + mz*(-0.019503229449446238 + 
  mz*(-0.01887191799551998 + mz*(-0.018280151105502133 + 
  mz*(-0.01772432965429394 + mz*(-0.017201278046393622 + 
  mz*(-0.016708183744829352 + mz*(-0.01624254686615387 + 
  mz*(-0.01580213794060253 + mz*(-0.015384962335762822 + 
  mz*(-0.014989230149475223 + mz*(-0.014613330616076985 + 
  mz*(-0.014255810256287103 + mz*(-0.013915354147406961 + 
  (-0.013590769806312237 - 0.013280973269869385*mz)*mz))))))))))))))))))))))))))))))))))))))))))
  + lnmz*lnmz*
  mz*mz*(0.125 + mz*(0.10416666666666667 + mz*(0.08333333333333333 + 
  mz*(0.06822916666666666 + mz*(0.05737847222222222 + 
  mz*(0.04936755952380952 + mz*(0.04326636904761905 + 
  mz*(0.03848612144510582 + mz*(0.03464835999503968 + 
  mz*(0.031502948006854256 + mz*(0.028879551889805795 + 
  mz*(0.02665883040028548 + mz*(0.02475496358683789 + 
  mz*(0.023104778002849293 + mz*(0.02166079295595897 + 
  mz*(0.020386656713676572 + mz*(0.01925407714035881 + 
  mz*(0.018240710236330077 + mz*(0.017328677234182827 + 
  mz*(0.016503503263119737 + mz*(0.015753344539944553 + 
  mz*(0.015068416752060183 + mz*(0.014440566162037104 + 
  mz*(0.013862943565226158 + mz*(0.013329753451026938 + 
  mz*(0.012836058889380043 + mz*(0.01237762821968696 + 
  mz*(0.011950813455784757 + mz*(0.011552453008329085 + 
  mz*(0.011179793234367566 + mz*(0.010830424696028287 + 
  mz*(0.010502230008380097 + mz*(0.010193340890538442 + 
  mz*(0.009902102579404659 + mz*(0.009627044174432746 + 
  mz*(0.009366853791345432 + mz*(0.00912035763894419 + 
  mz*(0.008886502314869926 + mz*(0.008664339756998762 + 
  mz*(0.00845301439707224 + mz*(0.008251752149523032 + 
  mz*(0.00805985093674349 + (0.007876672506362986 + 0.007701635339554934*mz)*mz))))))))))))))))))))))))))))))))))))))))))
  ;
  }
  else if ( z<-0.5 && z>=-1. ) {
  double pz = 1.+z;
  return
  -0.11412342741606056 + pz*(-0.0685988681377332 + 
  pz*(0.07893073433134454 + pz*(0.03288180542927854 + 
  pz*(0.01685506288725523 + pz*(0.010191014808358961 + 
  pz*(0.006868298519809669 + pz*(0.004971418202799324 + 
  pz*(0.0037787572380588927 + pz*(0.002975292171863528 + 
  pz*(0.0024059625004693996 + pz*(0.001986808185548375 + 
  pz*(0.0016688308223672225 + pz*(0.0014217008903892672 + 
  pz*(0.0012257460643420072 + pz*(0.0010677156464099086 + 
  pz*(0.0009384027443681137 + pz*(0.0008312412797336043 + 
  pz*(0.0007414431589395191 + pz*(0.0006654488335993344 + 
  pz*(0.0006005669007936813 + pz*(0.0005447315874420374 + 
  pz*(0.0004963358818804268 + pz*(0.00045411443497835047 + 
  pz*(0.0004170599325663774 + pz*(0.00038436242221184455 + 
  pz*(0.00035536466026233303 + pz*(0.00032952881839325675 + 
  pz*(0.00030641136194531 + pz*(0.0002856438850810869 + 
  pz*(0.0002669183412798877 + pz*(0.00024997555364565313 + 
  pz*(0.00023459619824738563 + pz*(0.00022059367032300353 + 
  pz*(0.00020780839703305083 + pz*(0.00019610327099146493 + 
  pz*(0.00018535995907544532 + pz*(0.00017547589989803762 + 
  pz*(0.00016636184692503213 + pz*(0.00015793984678462783 + 
  pz*(0.00015014156684953726 + pz*(0.00014290690479427503 + 
  pz*(0.00013618282707434336 + pz*(0.00012992239424506127 + 
  (0.00012408393954499268 + 
  0.00011863037380696866*pz)*pz)))))))))))))))))))))))))))))))))))))))))))
  + (pz>0.?log(pz):0.)*
  pz*(-0.2402265069591007 + pz*(-0.12011325347955035 + 
  pz*(-0.08007550231970023 + pz*(-0.060056626739775174 + 
  pz*(-0.048045301391820144 + pz*(-0.040037751159850116 + 
  pz*(-0.03431807242272867 + pz*(-0.030028313369887587 + 
  pz*(-0.026691834106566743 + pz*(-0.024022650695910072 + 
  pz*(-0.021838773359918247 + pz*(-0.020018875579925058 + 
  pz*(-0.01847896207377698 + pz*(-0.017159036211364335 + 
  pz*(-0.016015100463940047 + pz*(-0.015014156684943793 + 
  pz*(-0.014130970997594158 + pz*(-0.013345917053283371 + 
  pz*(-0.012643500366268457 + pz*(-0.012011325347955036 + 
  pz*(-0.011439357474242889 + pz*(-0.010919386679959123 + 
  pz*(-0.010444630737352203 + pz*(-0.010009437789962529 + 
  pz*(-0.009609060278364027 + pz*(-0.00923948103688849 + 
  pz*(-0.008897278035522248 + pz*(-0.008579518105682167 + 
  pz*(-0.008283672653762092 + pz*(-0.008007550231970023 + 
  pz*(-0.0077492421599709895 + pz*(-0.007507078342471897 + 
  pz*(-0.007279591119972749 + pz*(-0.007065485498797079 + 
  pz*(-0.006863614484545734 + pz*(-0.006672958526641686 + 
  pz*(-0.006492608296191911 + pz*(-0.006321750183134228 + 
  pz*(-0.006159654024592325 + pz*(-0.006005662673977518 + 
  pz*(-0.005859183096563432 + pz*(-0.005719678737121444 + 
  pz*(-0.005586662952537225 + (-0.005459693339979562 - 
  0.005338366821313349*pz)*pz)))))))))))))))))))))))))))))))))))))))))))
  ;
  }
  return 0.; // out of supported (-1,1) range
  }

  double h0pmm(double z) { return -h0mpp(-z); }

  double h0mpm(double z) { // HPL[{-2,1,-1},z]==HPL[{0,-1,1,-1},z]
  if ( z>=-0.5 && z<=0.5 ) {
  return
  z*z*z*(0.05555555555555555 + z*(-0.020833333333333332 + 
  z*(0.021666666666666667 + z*(-0.011805555555555555 + 
  z*(0.011337868480725623 + z*(-0.00730406746031746 + 
  z*(0.006943219674701157 + z*(-0.004918981481481482 + 
  z*(0.004681501158773886 + z*(-0.003526163586927476 + 
  z*(0.0033677291369599064 + z*(-0.0026474451474451472 + 
  z*(0.0025380073776899168 + z*(-0.0020591327385412208 + 
  z*(0.0019808779298089727 + z*(-0.0016465470985438694 + 
  z*(0.001588851655661967 + z*(-0.0013462886423628124 + 
  z*(0.0013026168415054336 + z*(-0.0011210904334913807 + 
  z*(0.0010872797204511684 + z*(-0.0009479163989575359 + 
  z*(0.0009212273643598981 + z*(-0.000811918938969265 + 
  z*(0.0007904946064612552 + z*(-0.0007031849668318024 + 
  z*(0.0006857329450488389 + z*(-0.0006148939495935666 + 
  z*(0.0006004935175182459 + z*(-0.0005422298463550487 + 
  z*(0.0005302113122006934 + z*(-0.00048171431593658354 + 
  z*(0.00047158148153858434 + z*(-0.0004307848005547207 + 
  z*(0.0004221638777505306 + z*(-0.0003875199479879333 + 
  z*(0.00038012513809507643 + z*(-0.00035045642164279123 + 
  z*(0.0003440662457901745 + z*(-0.00031846394480825063 + 
  z*(0.0003129046636360557 + (-0.0002906583580365446 + 
  0.00028579216034594967*z)*z)))))))))))))))))))))))))))))))))))))))))
  ;
  }
  else if ( z>0.5 && z<=1. ) {
  double mz = 1.-z;
  return
  0.05465305273826415 + mz*(-0.2140723708667061 + 
  mz*(0.0073338756603733195 + mz*(0.02710941725809516 + 
  mz*(0.022474368705672376 + mz*(0.01676722256048639 + 
  mz*(0.01248647606826693 + mz*(0.0094870649051908 + 
  mz*(0.007384574679053124 + mz*(0.005882884278342548 + 
  mz*(0.004784752258448703 + mz*(0.003962484837580535 + 
  mz*(0.003333023237178906 + mz*(0.002841440990476618 + 
  mz*(0.0024506529736376542 + mz*(0.002135068313063808 + 
  mz*(0.0018766470113983913 + mz*(0.001662412798038939 + 
  mz*(0.0014828553845727052 + mz*(0.0013308838613534345 + 
  mz*(0.0012011276037658183 + mz*(0.0010894603777749437 + 
  mz*(0.0009926704953424417 + mz*(0.0009082282922402464 + 
  mz*(0.0008341196009494234 + mz*(0.0007687247231704213 + 
  mz*(0.0007107292646835635 + mz*(0.0006590576109890764 + 
  mz*(0.0006128227119380387 + mz*(0.0005712877646092476 + 
  mz*(0.0005338366799734935 + mz*(0.0004999511060838971 + 
  mz*(0.0004691923959298516 + mz*(0.0004411873403811391 + 
  mz*(0.0004156167939416769 + mz*(0.0003922065419243743 + 
  mz*(0.0003707199181232808 + mz*(0.00035095179978304053 + 
  mz*(0.0003327236938438956 + mz*(0.0003158796935663344 + 
  mz*(0.00030028313369768675 + mz*(0.0002858138095878926 + 
  mz*(0.00027236565414837273 + mz*(0.0002598447884899751 + 
  (0.0002481678790899212 + 0.00023726074761389916*mz)*mz)))))))))))))))))))))))))))))))))))))))))))
  + (mz>0.?log(mz):0.)*
  mz*mz*(-0.17328679513998632 + mz*(-0.14440566261665527 + 
  mz*(-0.11552453009332421 + mz*(-0.0945857090139092 + 
  mz*(-0.07954345249134094 + mz*(-0.06843796939010768 + 
  mz*(-0.05997992343684645 + mz*(-0.05335309314072549 + 
  mz*(-0.04803282608317551 + mz*(-0.04367235918055515 + 
  mz*(-0.04003555993650705 + mz*(-0.03695698625796728 + 
  mz*(-0.034317666430161584 + mz*(-0.03203002346027686 + 
  mz*(-0.030028235132231365 + mz*(-0.02826190724425679 + 
  mz*(-0.026691818568246806 + mz*(-0.025286993743446253 + 
  mz*(-0.024022647535414273 + mz*(-0.022878713512386604 + 
  mz*(-0.02183877270450395 + mz*(-0.020889261174385526 + 
  mz*(-0.02001887544181074 + mz*(-0.019218120492996295 + 
  mz*(-0.018478962044277045 + mz*(-0.0177945560573504 + 
  mz*(-0.01715903620499046 + mz*(-0.016567345304550122 + 
  mz*(-0.016015100462549125 + mz*(-0.01549848431929006 + 
  mz*(-0.01501415668463762 + mz*(-0.014559182239801429 + 
  mz*(-0.014130970997526245 + mz*(-0.013727228969059403 + 
  mz*(-0.013345917053268208 + mz*(-0.01298521659237664 + 
  mz*(-0.01264350036626505 + mz*(-0.012319308049183034 + 
  mz*(-0.012011325347954268 + mz*(-0.011718366193126498 + 
  mz*(-0.011439357474242715 + mz*(-0.01117332590507437 + 
  (-0.010919386679959082 - 
  0.010676733642626678*mz)*mz))))))))))))))))))))))))))))))))))))))))))
  ;
  }
  else if ( z<-0.5 && z>=-1. ) {
  double pz = 1.+z;
  return
  -0.19355535381306507 + pz*(-0.49218586075106785 + 
  pz*(0.23334693800821307 + pz*(0.1232179294240857 + 
  pz*(0.07174755647041342 + pz*(0.04635862602279184 + 
  pz*(0.03229171243369372 + pz*(0.023749681712559423 + 
  pz*(0.01819045229917038 + pz*(0.014374858497650439 + 
  pz*(0.011644327203343019 + pz*(0.009623643094181455 + 
  pz*(0.00808661424607754 + pz*(0.006890398527579139 + 
  pz*(0.00594122164630978 + pz*(0.005175468204274641 + 
  pz*(0.004548752890706331 + pz*(0.004029345721257099 + 
  pz*(0.003594077130726972 + pz*(0.0032257092096935336 + 
  pz*(0.002911202600321572 + pz*(0.0026405465920596866 + 
  pz*(0.0024059525831864187 + pz*(0.0022012874323344422 + 
  pz*(0.0020216684936900375 + pz*(0.0018631696842704298 + 
  pz*(0.0017226051077056242 + pz*(0.0015973676994152919 + 
  pz*(0.0014853074654384985 + pz*(0.0013846385884872386 + 
  pz*(0.0012938678365825296 + pz*(0.0012117388688109715 + 
  pz*(0.0011371885282507321 + pz*(0.0010693122616431822 + 
  pz*(0.0010073365509772753 + pz*(0.0009505967779019631 + 
  pz*(0.0008985193309644646 + pz*(0.0008506070510810801 + 
  pz*(0.0008064273219736962 + pz*(0.0007656022701709522 + 
  pz*(0.0007278006580812638 + pz*(0.0006927311439203082 + 
  pz*(0.0006601366513208778 + pz*(0.0006297896446349482 + 
  (0.0006014881471745892 + 0.0005750523718172987*pz)*pz)))))))))))))))))))))))))))))))))))))))))))
  + (pz>0.?log(pz):0.)*
  pz*(-0.5822405264650126 + pz*(-0.5411202632325063 + 
  pz*(-0.3815801754883375 + pz*(-0.2896573538384753 + 
  pz*(-0.23250713307078028 + pz*(-0.19396427755898357 + 
  pz*(-0.1663170990188113 + pz*(-0.14554739148839865 + 
  pz*(-0.1293822407848266 + pz*(-0.11644642797177603 + 
  pz*(-0.10586127684934185 + pz*(-0.09703984006041598 + 
  pz*(-0.08957536739584607 + pz*(-0.08317717846111 + 
  pz*(-0.07763205399062657 + pz*(-0.07278005909331743 + 
  pz*(-0.06849888265280729 + pz*(-0.06469339063872294 + 
  pz*(-0.06128847596161947 + pz*(-0.0582240524277142 + 
  pz*(-0.055451478616117614 + pz*(-0.05293095690998788 + 
  pz*(-0.05062961097879712 + pz*(-0.048520043864070085 + 
  pz*(-0.0465792421136465 + pz*(-0.04478773280341715 + 
  pz*(-0.04312892788558849 + pz*(-0.04158860903289677 + 
  pz*(-0.040154519066409 + pz*(-0.03881603509760253 + 
  pz*(-0.03756390493319712 + pz*(-0.036390032904049845 + 
  pz*(-0.03528730463423705 + pz*(-0.03424944273323322 + 
  pz*(-0.03327088722657086 + pz*(-0.03234669591472232 + 
  pz*(-0.03147246089000041 + pz*(-0.030644238235000527 + 
  pz*(-0.02985848853666725 + pz*(-0.029112026323250596 + 
  pz*(-0.0284019769007323 + pz*(-0.02772573935547678 + 
  pz*(-0.027080954719302903 + (-0.026465478475682383 - 
  0.025877356731778337*pz)*pz)))))))))))))))))))))))))))))))))))))))))))
  ;
  }
  return 0.; // out of supported (-1,1) range
  }

  double h0pmp(double z) { return -h0mpm(-z); }

  double h0mmp(double z) { // HPL[{-2,-1,1},z]==HPL[{0,-1,-1,1},z]
  if ( z>=-0.5 && z<=0.5 ) {
  return
  z*z*z*(0.05555555555555555 + z*(-0.041666666666666664 + 
  z*(0.035 + z*(-0.027546296296296298 + z*(0.02290249433106576 + 
  z*(-0.018911210317460316 + z*(0.01611429551244366 + 
  z*(-0.01375760582010582 + z*(0.011986149372513008 + 
  z*(-0.010479292762278875 + z*(0.009292288907673522 + 
  z*(-0.008268590819611227 + z*(0.0074346498298879255 + 
  z*(-0.006705898010306493 + z*(0.0060970437068744035 + 
  z*(-0.005558759546522476 + z*(0.005100089420606755 + 
  z*(-0.00469048067896971 + z*(0.004335897600332551 + 
  z*(-0.004016481609588271 + z*(0.0037363710800558847 + 
  z*(-0.003482137895258143 + z*(0.0032567658953505376 + 
  z*(-0.003050870687242306 + z*(0.002866669341485365 + 
  z*(-0.002697417734766521 + z*(0.0025448036823387554 + 
  z*(-0.002403863054443063 + z*(0.0022759068311129873 + 
  z*(-0.002157204465202193 + z*(0.0020487916700514513 + 
  z*(-0.0019478135799739578 + z*(0.0018551004604995679 + 
  z*(-0.001768432312868687 + z*(0.0016884832173844973 + 
  z*(-0.0016135021248928512 + z*(0.0015440424710672668 + 
  z*(-0.0014787054118171614 + z*(0.001417949877128064 + 
  z*(-0.0013606455238003431 + z*(0.001307176326882162 + 
  (-0.0012566194061515673 + 0.0012092986241240649*z)*z)))))))))))))))))))))))))))))))))))))))))
  ;
  }
  else if ( z>0.5 && z<=1. ) {
  double mz = 1.-z;
  return
  0.03415912616651381 + mz*(-0.09475300423012771 + 
  mz*(0.09818362950118927 + mz*(0.013326886047946154 + 
  mz*(-0.0034710799800298474 + mz*(-0.005913959561042941 + 
  mz*(-0.00539963473394954 + mz*(-0.004439597078933693 + 
  mz*(-0.003578229029846605 + mz*(-0.002897245618103457 + 
  mz*(-0.0023748030042230073 + mz*(-0.0019741055850988603 + 
  mz*(-0.0016635614927285186 + mz*(-0.0014194826129062827 + 
  mz*(-0.0012248003542985955 + mz*(-0.0010673080338609656 + 
  mz*(-0.0009382253714464066 + mz*(-0.0008311634428853788 + 
  mz*(-0.0007414087452562411 + mz*(-0.0006654335163885344 + 
  mz*(-0.0006005600421642226 + mz*(-0.0005447284996172932 + 
  mz*(-0.0004963344848414241 + mz*(-0.00045411380006220477 + 
  mz*(-0.0004170596428245436 + mz*(-0.0003843622894882876 + 
  mz*(-0.00035536459925268257 + mz*(-0.00032952879025812277 + 
  mz*(-0.00030641134893170854 + mz*(-0.0002856438790450246 + 
  mz*(-0.00026691833847293945 + mz*(-0.00024997555233717376 + 
  mz*(-0.0002345961976360409 + mz*(-0.00022059367003676679 + 
  mz*(-0.00020780839689876155 + mz*(-0.00019610327092834529 + 
  mz*(-0.00018535995904572083 + mz*(-0.00017547589988401932 + 
  mz*(-0.00016636184691840635 + mz*(-0.00015793984678149318 + 
  mz*(-0.0001501415668480519 + mz*(-0.00014290690479357247 + 
  mz*(-0.0001361828270740077 + mz*(-0.0001299223942449021 + 
  (-0.00012408393954492026 - 0.00011863037380693267*mz)*mz)))))))))))))))))))))))))))))))))))))))))))
  + (mz>0.?log(mz):0.)*
  mz*mz*mz*(0.04166666666666666 + mz*(0.046875 + mz*(0.043229166666666666 + 
  mz*(0.03819444444444445 + mz*(0.0335875496031746 + 
  mz*(0.029730902777777776 + mz*(0.02656814063877866 + 
  mz*(0.02397030784970238 + mz*(0.02181630408437049 + 
  mz*(0.020009113291583995 + mz*(0.018474676850836515 + 
  mz*(0.017157138448838538 + mz*(0.01601425350444283 + 
  mz*(0.015013776117945691 + mz*(0.014130798964523404 + 
  mz*(0.013345838868178288 + mz*(0.012643464661232071 + 
  mz*(0.012011308971301034 + mz*(0.011439349933115727 + 
  mz*(0.010919383194891753 + mz*(0.010444629121440415 + 
  mz*(0.010009437038444216 + mz*(0.009609059927874974 + 
  mz*(0.009239480873006438 + mz*(0.008897277958710197 + 
  mz*(0.008579518069599733 + mz*(0.00828367263677709 + 
  mz*(0.008007550223959149 + mz*(0.0077492421561858186 + 
  mz*(0.007507078340680325 + mz*(0.007279591119123409 + 
  mz*(0.0070654854983938165 + mz*(0.006863614484353993 + 
  mz*(0.006672958526550393 + mz*(0.006492608296148389 + 
  mz*(0.006321750183113456 + mz*(0.006159654024582399 + 
  mz*(0.00600566267397277 + mz*(0.005859183096561158 + 
  mz*(0.005719678737120355 + mz*(0.0055866629525367015 + 
  (0.00545969333997931 + 0.005338366821313228*mz)*mz)))))))))))))))))))))))))))))))))))))))))
  ;
  }
  else if ( z<-0.5 && z>=-1. ) {
  double pz = 1.+z;
  double lnpz = pz>0.?log(pz):0.;
  return
  -0.4336923770489553 + pz*(0.6481198477029728 + 
  pz*(-0.04031013724223986 + pz*(-0.037033542828249305 + 
  pz*(-0.0252262172132115 + pz*(-0.017673043318438858 + 
  pz*(-0.012946499652811805 + pz*(-0.00985667053188985 + 
  pz*(-0.007742219320544946 + pz*(-0.0062368624529948735 + 
  pz*(-0.005129100287172894 + pz*(-0.004291078768105014 + 
  pz*(-0.003642190602593312 + pz*(-0.0031297059176522007 + 
  pz*(-0.00271800757999216 + pz*(-0.002382357699906121 + 
  pz*(-0.0021051512693120306 + pz*(-0.0018735886403995067 + 
  pz*(-0.001678186201223765 + pz*(-0.0015117980238878864 + 
  pz*(-0.001368957908060478 + pz*(-0.0012454274738023796 + 
  pz*(-0.001137879825538854 + pz*(-0.0010436742762266887 + 
  pz*(-0.0009606933919367594 + pz*(-0.0008872234226504627 + 
  pz*(-0.0008218654134326542 + pz*(-0.0007634683246199245 + 
  pz*(-0.000711078150520135 + pz*(-0.0006638988103984528 + 
  pz*(-0.0006212618004938428 + pz*(-0.0005826024349578005 + 
  pz*(-0.0005474410908907212 + pz*(-0.0005153682887491656 + 
  pz*(-0.00048603273761569504 + pz*(-0.0004591316908621329 + 
  pz*(-0.00043440311583032784 + pz*(-0.00041161929794178084 + 
  pz*(-0.00039058158669467644 + pz*(-0.00037111605643344245 + 
  pz*(-0.0003530699043443851 + pz*(-0.0003363084459672011 + 
  pz*(-0.0003207125975997517 + pz*(-0.0003061767574859507 + 
  (-0.0002926070152129562 - 0.00027991963248686497*pz)*pz)))))))))))))))))))))))))))))))))))))))))))
  + lnpz*
  pz*(-0.11090665409493289 + pz*(0.11783346809251993 + 
  pz*(0.117063822092788 + pz*(0.10223843283125653 + 
  pz*(0.08872221807060468 + pz*(0.07778599939528139 + 
  pz*(0.06903135723867637 + pz*(0.0619496411118774 + 
  pz*(0.05613601922994034 + pz*(0.05129258084090178 + 
  pz*(0.04720246785582804 + pz*(0.043706521784862534 + 
  pz*(0.04068627019813738 + pz*(0.03805214382627668 + 
  pz*(0.03573538096184552 + pz*(0.03368242673000099 + 
  pz*(0.03185100958250957 + pz*(0.03020735276484654 + 
  pz*(0.028724162942590836 + pz*(0.02737915837185076 + 
  pz*(0.026153977041281893 + pz*(0.0250333562017982 + 
  pz*(0.024004508370766238 + pz*(0.023056641414236724 + 
  pz*(0.02218058556970459 + pz*(0.021368500750784582 + 
  pz*(0.02061364476542578 + pz*(0.019910188214872962 + 
  pz*(0.019253065501694904 + pz*(0.018637854014878254 + 
  pz*(0.018060675483720548 + pz*(0.01751811490851607 + 
  pz*(0.01700715352872862 + pz*(0.0165251130789364 + 
  pz*(0.016069609180175914 + pz*(0.015638512169892364 + 
  pz*(0.015229914023846249 + pz*(0.014842100294397871 + 
  pz*(0.01447352620090437 + pz*(0.014122796173775345 + 
  pz*(0.013788646284655304 + pz*(0.01346992909918967 + 
  pz*(0.01316560057189594 + (0.012874708669370146 + 
  0.012596383461908948*pz)*pz)))))))))))))))))))))))))))))))))))))))))))
  + lnpz*lnpz*
  pz*(0.34657359027997264 + pz*(0.17328679513998632 + 
  pz*(0.11552453009332421 + pz*(0.08664339756999316 + 
  pz*(0.06931471805599453 + pz*(0.057762265046662105 + 
  pz*(0.049510512897138946 + pz*(0.04332169878499658 + 
  pz*(0.03850817669777474 + pz*(0.03465735902799726 + 
  pz*(0.03150669002545206 + pz*(0.028881132523331052 + 
  pz*(0.026659506944613283 + pz*(0.024755256448569473 + 
  pz*(0.023104906018664842 + pz*(0.02166084939249829 + 
  pz*(0.02038668178117486 + pz*(0.01925408834888737 + 
  pz*(0.018240715277893296 + pz*(0.01732867951399863 + 
  pz*(0.016503504299046314 + pz*(0.01575334501272603 + 
  pz*(0.015068416968694463 + pz*(0.014440566261665526 + 
  pz*(0.013862943611198907 + pz*(0.013329753472306641 + 
  pz*(0.012836058899258245 + pz*(0.012377628224284737 + 
  pz*(0.01195081345793009 + pz*(0.011552453009332421 + 
  pz*(0.011179793234837827 + pz*(0.010830424696249145 + 
  pz*(0.01050223000848402 + pz*(0.01019334089058743 + 
  pz*(0.00990210257942779 + pz*(0.009627044174443685 + 
  pz*(0.009366853791350613 + pz*(0.009120357638946648 + 
  pz*(0.008886502314871094 + pz*(0.008664339756999316 + 
  pz*(0.008453014397072503 + pz*(0.008251752149523157 + 
  pz*(0.00805985093674355 + (0.007876672506363015 + 
  0.007701635339554948*pz)*pz)))))))))))))))))))))))))))))))))))))))))))
  ;
  }
  return 0.; // out of supported (-1,1) range
  }

  double h0ppm(double z) { return -h0mmp(-z); }

  double hmpmp(double z) { // HPL[{-1,1,-1,1},z]
  if ( z>=-0.5 && z<=0.5 ) {
  return
  z*z*z*z*(0.041666666666666664 + z*(-0.016666666666666666 + 
  z*(0.03194444444444444 + z*(-0.017261904761904763 + 
  z*(0.02502480158730159 + z*(-0.015751763668430334 + 
  z*(0.020425485008818346 + z*(-0.014096821388488055 + 
  z*(0.017213462334990114 + z*(-0.01263442961359628 + 
  z*(0.014859147411230745 + z*(-0.011397588779533225 + 
  z*(0.013064621397396696 + z*(-0.010358106973040446 + 
  z*(0.011653485741580007 + z*(-0.00948025766182371 + 
  z*(0.010515653851611392 + z*(-0.008732728770712933 + 
  z*(0.009579193538935714 + z*(-0.008090359492164145 + 
  z*(0.008795237578756342 + z*(-0.007533428332606854 + 
  z*(0.008129476631698801 + z*(-0.007046537037443257 + 
  z*(0.007557137656622207 + z*(-0.006617609493590735 + 
  z*(0.007059897690684922 + z*(-0.006237100394604537 + 
  z*(0.0066239191023689465 + z*(-0.005897395642195295 + 
  z*(0.0062385596910314 + z*(-0.0055923640786635365 + 
  z*(0.005895502627974284 + z*(-0.005317022751002818 + 
  z*(0.005588155401680892 + z*(-0.0050672858266751905 + 
  z*(0.0053112256906510105 + z*(-0.004839774896593385 + 
  z*(0.005060416353279188 + z*(-0.004631674445483242 + 
  (0.004832202311184768 - 0.0044406207541893734*z)*z))))))))))))))))))))))))))))))))))))))))
  ;
  }
  else if ( z>0.5 && z<=1. ) {
  double mz = 1.-z;
  return
  0.08798553701050899 + mz*(0.24609293037553392 + 
  mz*(-0.21458673450205326 + mz*(-0.07443001895578849 + 
  mz*(-0.027116962441437874 + mz*(-0.010512925089832613 + 
  mz*(-0.004265294166112886 + mz*(-0.0017883813836375435 + 
  mz*(-0.0007684289781419635 + mz*(-0.00033643686047900436 + 
  mz*(-0.00014949593846635365 + mz*(-0.0000672255200925189 + 
  mz*(-0.00003052767484071651 + mz*(-0.000013976751918255964 + 
  mz*(-6.443582860963274e-6 + mz*(-2.9883203954079736e-6 + 
  mz*(-1.39302917442181e-6 + mz*(-6.522970706135979e-7 + 
  mz*(-3.066556623261132e-7 + mz*(-1.4467170777881253e-7 + 
  mz*(-6.846687723253703e-8 + mz*(-3.249401840881933e-8 + 
  mz*(-1.5460867023804742e-8 + mz*(-7.373429969531524e-9 + 
  mz*(-3.5238852674302056e-9 + mz*(-1.68737971423498e-9 + 
  mz*(-8.09421102950776e-10 + mz*(-3.889077297372145e-10 + 
  mz*(-1.8714380761200702e-10 + mz*(-9.018066990148548e-11 + 
  mz*(-4.3512879922506795e-11 + mz*(-2.102084462295594e-11 + 
  mz*(-1.0166601628444723e-11 + mz*(-4.922246917799664e-12 + 
  mz*(-2.3855276275573525e-12 + mz*(-1.1572122842251978e-12 + 
  mz*(-5.618565705832273e-13 + mz*(-2.7302351289460265e-13 + 
  mz*(-1.3277517650675226e-13 + mz*(-6.461861726019764e-14 + 
  mz*(-3.147063321348631e-14 + mz*(-1.533715279770961e-14 + 
  mz*(-7.479300806628426e-15 + mz*(-3.649562835123495e-15 + 
  (-1.781852795561264e-15 - 8.704470057740011e-16*mz)*mz)))))))))))))))))))))))))))))))))))))))))))
  + (mz>0.?log(mz):0.)*
  mz*(0.2911202632325063 + mz*(0.19778006580812657 + 
  mz*(0.07634335526937552 + mz*(0.030364869337126926 + 
  mz*(0.01253657273485077 + mz*(0.005327738639521155 + 
  mz*(0.002314318543921765 + mz*(0.0010224792864351598 + 
  mz*(0.00045782608042951547 + mz*(0.00020722736890933135 + 
  mz*(0.00009463815064060516 + mz*(0.000043543959969919243 + 
  mz*(0.000020162420794075976 + mz*(9.386920709443136e-6 + 
  mz*(4.390943126354075e-6 + mz*(2.062493142995834e-6 + 
  mz*(9.72338086256139e-7 + mz*(4.598929654274954e-7 + 
  mz*(2.1815387196546276e-7 + mz*(1.0375517703905274e-7 + 
  mz*(4.946399348981121e-8 + mz*(2.363238924280276e-8 + 
  mz*(1.1313155732863158e-8 + mz*(5.42558187977697e-9 + 
  mz*(2.6063489080143138e-9 + mz*(1.253969354157272e-9 + 
  mz*(6.041712286286999e-10 + mz*(2.9147934728825257e-10 + 
  mz*(1.4079609258379186e-10 + mz*(6.808835804945164e-11 + 
  mz*(3.296267007006829e-11 + mz*(1.597386455100013e-11 + 
  mz*(7.748349080415868e-12 + mz*(3.761800305524928e-12 + 
  mz*(1.8278794719385227e-12 + mz*(8.8888249648323e-13 + 
  mz*(4.3258105679794335e-13 + mz*(2.1066860393295533e-13 + 
  mz*(1.0266572211996783e-13 + mz*(5.006448849307953e-14 + 
  mz*(2.442863382819255e-14 + mz*(1.1926720343784492e-14 + 
  mz*(5.826176175352981e-15 + (2.847580240003879e-15 + 1.3924765758915934e-15*mz)*mz)))))))))))))))))))))))))))))))))))))))))))
  ;
  }
  else if ( z<-0.5 && z>=-1. ) {
  double pz = 1.+z;
  return
  -0.49371712737028806 + pz*(0.4020269173274391 + 
  pz*(0.0694316658809333 + pz*(0.015692466582059503 + 
  pz*(0.004396266308304966 + pz*(0.0013982868210875958 + 
  pz*(0.00048282102640310207 + pz*(0.00017652908386677808 + 
  pz*(0.00006731221440607721 + pz*(0.000026504972812506784 + 
  pz*(0.000010704654695444504 + pz*(4.412908238649827e-6 + 
  pz*(1.8502404066378613e-6 + pz*(7.868653353064493e-7 + 
  pz*(3.387059729481854e-7 + pz*(1.4732190437963725e-7 + 
  pz*(6.466169086396503e-8 + pz*(2.86076617417035e-8 + 
  pz*(1.2746064079990868e-8 + pz*(5.714730848999715e-9 + 
  pz*(2.5766788375473144e-9 + pz*(1.1676960625553305e-9 + 
  pz*(5.316161277841242e-10 + pz*(2.430449980466742e-10 + 
  pz*(1.1154233488994542e-10 + pz*(5.137131936887665e-11 + 
  pz*(2.3736092532333866e-11 + pz*(1.1000147599495425e-11 + 
  pz*(5.112031617622093e-12 + pz*(2.3818218777474496e-12 + 
  pz*(1.1124216558854651e-12 + pz*(5.207211380411294e-13 + 
  pz*(2.442611441092387e-13 + pz*(1.148049265939941e-13 + 
  pz*(5.405952788864877e-14 + pz*(2.5500145993340014e-14 + 
  pz*(1.2048385824864336e-14 + pz*(5.701530783449112e-15 + 
  pz*(2.7020555601436066e-15 + pz*(1.2823420650561823e-15 + 
  pz*(6.093817976136052e-16 + pz*(2.899495875043312e-16 + 
  pz*(1.3812632784046412e-16 + pz*(6.587593450938333e-17 + 
  (3.1452166472638903e-17 + 1.5032334991887733e-17*pz)*pz)))))))))))))))))))))))))))))))))))))))))))
  + (pz>0.?log(pz):0.)*
  (-0.21407237086670605 + pz*(-0.34657359027997264 + 
  pz*(-0.04332169878499658 + pz*(-0.009627044174443685 + 
  pz*(-0.0027076061740622863 + pz*(-0.0008664339756999317 + 
  pz*(-0.00030084513045136515 + pz*(-0.000110514537716828 + 
  pz*(-0.00004230634646972322 + pz*(-0.000016713618358409172 + 
  pz*(-6.769015435155716e-6 + pz*(-2.797113816180048e-6 + 
  pz*(-1.1751762908256451e-6 + pz*(-5.00666822126902e-7 + 
  pz*(-2.158487064781797e-7 + pz*(-9.40141032660516e-8 + 
  pz*(-4.1314791474339085e-8 + pz*(-1.829859276372112e-8 + 
  pz*(-8.160946464066979e-9 + pz*(-3.662252983874933e-9 + 
  pz*(-1.6525916589735635e-9 + pz*(-7.494746752714573e-10 + 
  pz*(-3.41444557639166e-10 + pz*(-1.561995896950438e-10 + 
  pz*(-7.172706853183869e-11 + pz*(-3.305183317947127e-11 + 
  pz*(-1.527913885885321e-11 + pz*(-7.084154916724808e-12 + 
  pz*(-3.2935898815640213e-12 + pz*(-1.535181014950174e-12 + 
  pz*(-7.172706853183869e-13 + pz*(-3.358707683592863e-13 + 
  pz*(-1.5760342206702837e-13 + pz*(-7.409821129322179e-14 + 
  pz*(-3.490179589027618e-14 + pz*(-1.646794940782011e-14 + 
  pz*(-7.782885040347079e-15 + pz*(-3.683936819682182e-15 + 
  pz*(-1.746298305451838e-15 + pz*(-8.289463356582689e-16 + 
  pz*(-3.9400855516757095e-16 + pz*(-1.8751150751579819e-16 + 
  pz*(-8.934434357541291e-17 + pz*(-4.2618556535161813e-17 + 
  (-2.035168156857288e-17 - 9.72860630043385e-18*pz)*pz))))))))))))))))))))))))))))))))))))))))))))
  ;
  }
  return 0.; // out of supported (-1,1) range
  }

  double hpmpm(double z) { return hmpmp(-z); }

